package com.developmentReformProject.service.impl;

import com.developmentReformProject.dao.SysLogDao;
import com.developmentReformProject.dto.LogQueryDto;
import com.developmentReformProject.entity.Admin;
import com.developmentReformProject.entity.SysLog;
import com.developmentReformProject.service.SysLogService;
import com.developmentReformProject.utils.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysLogServiceImpl implements SysLogService {
    @Autowired
    SysLogDao sysLogDao;
    @Override
    public void save(SysLog sysLog) throws Exception {
        sysLogDao.save(sysLog);
    }

    @Override
    public PageUtil<SysLog> pageList(LogQueryDto logQueryDto) throws Exception {
        PageUtil<SysLog> pageUtil=null;
        //统计满足条件记录总数
        int total=sysLogDao.countSelective(logQueryDto);
        /*
         * 如果total>0,查询数据
         * 封装到pageUtil
         */
        if(total>0){
            List<SysLog> data=sysLogDao.selectSelective(logQueryDto);
            pageUtil=new PageUtil<>(total, data, logQueryDto.getCurrentPage(), logQueryDto.getPageSize());
        }
        return pageUtil;
    }
}
